package com.investigacion.corta;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.support.v4.app.NavUtils;

public class MainActivity extends Activity {
	
	
	int var1;
	int var2;
	int var3;
	EditText num1;
	EditText num2;
	Button result;
	TextView display;
	

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		num1= (EditText) findViewById(R.id.numero1);
		num2= (EditText) findViewById(R.id.numero2);
		result = (Button) findViewById(R.id.bresultado);
		display=(TextView) findViewById(R.id.resultado);
result.setOnClickListener(new View.OnClickListener() {
			
	public void onClick(View v) {
		// TODO Auto-generated method stub
		try{
			var1=Integer.parseInt(num1.getText().toString());
			var2=Integer.parseInt(num2.getText().toString());
			var3=var1+var2;
			display.setText(String.valueOf(var3));
		}
		catch(Exception e){
			display.setText("ERROR al ingresar los datos");
			
		}
		
		
	}
});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

}
